package com.lysj.bhp.util.sms;


import com.lysj.bhp.util.http.HttpUtil;
import com.lysj.bhp.util.web.ParamUtil;

/**
 * 未来无限短信接口
 *
 * @author jefu3
 */
public class SmsWLWXUtil {
    // 发送短信地址
    private final static String url_send_sms = "http://43.243.130.33:8860/sendSms";
    // 用户账号，必填
    private final static String cust_code = "500225";
    // 用户密码，必填
    private final static String cust_pwd = "XIFVGBCUMQ";
    // 业务标识，选填，由客户自行填写不超过20位的数字
    private final static String uid = "0000";
    // 长号码，选填
    private final static String sp_code = "";
    // 是否需要状态报告
    private final static String need_report = "yes";

    /**
     * 发送普通短信
     *
     * @param content
     * @param phone
     * @return
     */
    public static boolean sendSms(String content, String phone) {
        // 签名，签名内容根据 “短信内容+客户密码”进行MD5编码后获得
        String sign = content + cust_pwd;
        sign = ParamUtil.md5(sign);

        StringBuilder sb = new StringBuilder();
        sb.append("{\"cust_code\":\"").append(cust_code).append("\",\"sp_code\":\"").append(sp_code);
        sb.append("\",\"content\":\"").append(content).append("\",\"destMobiles\":\"").append(phone);
        sb.append("\",\"uid\":\"").append(uid).append("\",\"need_report\":\"").append(need_report);
        sb.append("\",\"sign\":\"").append(sign).append("\"}");
//		String resp = HttpUtil.sendJsonPost(url_send_sms, sb.toString());
        String resp = HttpUtil.sendJsonPost(url_send_sms, sb.toString());
        if (ParamUtil.isBlack(resp)) {
            return false;
        } else {
            return true;
        }
    }

    // public static void main(String[] args) {
    // sendSms("您好,您的短信验证码为:123456", "18344989229,18305983207");
    // }

}
